import { reqGoodsList } from "@/api"

export default {
    state: {
        goodsList: {}
    },
    mutations: {
        UPDATE_GOODSLIST(state, goodsList) {
            state.goodsList = goodsList
        }
    },
    actions: {
        async getGoodsList({ commit }, searchParams) {
            const res = await reqGoodsList(searchParams)
            if (res.code === 200) {
                commit('UPDATE_GOODSLIST', res.data)
            }
        }
    },
    getters: {
        attrsList(state) {
            return state.goodsList.attrsList || []
        },
        trademarkList(state) {
            return state.goodsList.trademarkList || []
        },
        goodsList(state) {
            return state.goodsList.goodsList || []
        }
    }
}